home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ham Radio 2000
/
Ham Radio 2000.iso
/
ham2000
/
tcp_ip
/
os2
/
pmnos11s
/
calldbd.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-07-30
|
2KB
|
122 lines
/* Callbook server */
#include <stdio.h>
#include <string.h>
#include "global.h"
#include "files.h"
#include "mbuf.h"
#include "socket.h"
#include "session.h"
#include "proc.h"
#include "dirutil.h"
#include "commands.h"
#include "mailbox.h"
#include "config.h"
extern char *Callserver; /* buckbook.c */
static int Scallbook = -1; /* Prototype socket for service */
static void calldbd __ARGS((int s,void *unused,void *p));
int cb_lookup(int s,char *call); /* in buckbook.c */
/* Start up callsign database service */
int
cdbstart(argc,argv,p)
int argc;
char *argv[];
void *p;
{
struct sockaddr_in lsocket;
int s;
if(Scallbook != -1){
return 0;
}
psignal(Curproc,0); /* Don't keep the parser waiting */
chname(Curproc,"Callbook listener");
lsocket.sin_family = AF_INET;
lsocket.sin_addr.s_addr = INADDR_ANY;
if(argc < 2)
lsocket.sin_port = IPPORT_CALLDB;
else
lsocket.sin_port = atoi(argv[1]);
Scallbook = socket(AF_INET,SOCK_STREAM,0);
bind(Scallbook,(char *)&lsocket,sizeof(lsocket));
listen(Scallbook,1);
for(;;){
if((s = accept(Scallbook,NULLCHAR,(int *)NULL)) == -1)
break; /* Service is shutting down */
/* Spawn a server */
newproc("calldbd",1024,calldbd,s,NULL,NULL,0);
}
return 0;
}
static void
calldbd(s,unused,p)
int s;
void *unused;
void *p;
{
char user[80];
FILE *fp;
char *file,*cp;
sockmode(s,SOCK_ASCII);
sockowner(s,Curproc);
recvline(s,user,80);
rip(user);
log(s,"Callbook lookup: %s",user);
if(strlen(user) == 0)
{
usprintf(s,"No Callbook information available\n");
}
else
{
cb_lookup(s,user);
}
close_s(s);
/* log(s,"close Callbook"); */
}
int
cdb0(argc,argv,p)
int argc;
char *argv[];
void *p;
{
close_s(Scallbook);
Scallbook = -1;
return 0;
}
/* This routine has been expanded upon, and is now located in buckbook.c
- kb7yw Mon 01-27-1992
int
docallserver(argc,argv,p)
int argc;
char *argv[];
void *p;
{
if(argc < 2)
{
if(Callserver != NULLCHAR)
tprintf("The callserver's host name is: %s\n",Callserver);
else
{
tprintf("Callserver not configured!\n");
tprintf("Usage: callserver hostname OR callserver ip_address\n");
}
}
else {
if(Callserver != NULLCHAR)
free(Callserver);
Callserver = strdup(argv[1]);
}
return 0;
}
*/